var htmlStart='<section class="content"> ' +
    '<div class="row"> ' +
    '<div class="col-xs-12"> ' +
    '<div class="box-body table-responsive no-padding"> ' +
    '<form id="subjectviodeform" class="form-horizontal" method="post" enctype="multipart/form-data">' +
    '<table class="table table-hover"> ' +
    '<tbody>' +
    '<thead> ' +
    '<tr>' +
    '<th>标题</th>' +
    '<th>类型</th> ' +
    '<th>描述</th> ' +
    '<th>时间</th> ' +
    '<th style="text-align: center">操作</th> ' +
    '</tr> ' +
    '</thead>' +
    '<tbody id="bodycontent"> ';



var htmlend= '</tbody> ' +
    '</table>' +
    '</form> ' +
    '</div> ' +
    '</div> ' +
    '</div> ' +
    '</section>';




function SubjectInfo(html) {
    dialog({
        title: '视频来源',
        content: html,
        cancel: true,
        okValue: '确定',

        ok: function () {
            var options = {
                url: '/api/subject/updatesubjectvideo',
                type: 'post',
                success: function (data) {
                    if (data) {
                        if (data.code == 'OperateOk') {
                            dialog({
                                title: '提示',
                                content: '操作成功！',
                                cancel: false,
                                ok: function () {
                                }
                            }).width(320).showModal();
                        }
                        else {
                            dialog({
                                title: '提示',
                                content: '操作失败！',
                                cancel: false,
                                ok: function () {
                                }
                            }).width(320).showModal();
                            LoadfilmSubjectList();
                        }
                    }
                }
            };
            $("#SubjectVideoform").ajaxSubmit(options);
        }
    }).showModal().width(550).height(650)
}









function SubjectVideoContact(objectid) {

    var user_data = {
    };

    function SubjectSearchList() {
        SubjectLoadList();
    }
    //加载列表
    SubjectSearchList();
    function SubjectLoadList() {
        $.ajax({
                url: '/api/subject/subjectvideoalllist',
                type: 'get',
                dataType: 'json',
                data: {videoid: objectid},
                success: function (data) {
                    if (mortise_layout.ValidataResult(data)) {
                        if (data.result) {
                            user_data.allcount = data.result.count;
                            var html = '';
                            var VideoHtml = '';
                            $.each(data.result, function (index, item) {
                                html += getHtml(item);
                            })
                            VideoHtml=getVideoHtml(objectid);
                            html=htmlStart+VideoHtml+html+htmlend;
                            SubjectInfo(html);
                        }
                        else {
                            alert('返回数据错误！');
                        }
                    }
                    else {
                        alert('请求数据失败！');
                    }
                }
            }
        );
    }
    function  getHtml(dataObject) {

        var fCheckHtml = '';
        if (dataObject.fCheck == 1) {
            fCheckHtml = '<div class="checkbox"><input type="checkbox" name="subjectId" checked="checked" value="'+dataObject.fId+'"></div>';
        }
        else{
            fCheckHtml = '<div class="checkbox"><input type="checkbox" name="subjectId" value="'+dataObject.fId+'" ></div>';
        }


        return ' <tr>'+
            '<td>'+dataObject.fTitle+'</td>'+
            '<td>'+dataObject.fType+'</td>'+
            '<td>'+dataObject.fDesc +'</td>'+
            '<td>'+dataObject.fIntime+'</td>'+
            '<td>' +
            fCheckHtml+
            '</tr>';
    }

    function  getVideoHtml(objectid) {


        return '<input type="hidden" name="videoid" value="'+objectid+'">' ;
    }

};


function  SubjectInfo(html) {
    dialog({
        title: '专题信息',
        content: html,
        cancel: true,
        okValue: '确定',

        ok: function () {
            var options = {
                url: '/api/subject/updatesubjectvideo',
                type: 'post',
                success: function (data) {
                    if (data) {
                        if (data.code == 'OperateOk') {
                            dialog({
                                title: '提示',
                                content: '操作成功！',
                                cancel: false,
                                ok: function () {
                                }
                            }).width(320).showModal();
                            searchSubjectList();
                        }
                        else {
                            dialog({
                                title: '提示',
                                content: '操作失败！',
                                cancel: false,
                                ok: function () {
                                }
                            }).width(320).showModal();
                            searchSubjectList();
                        }
                    }
                }
            };
            $("#subjectviodeform").ajaxSubmit(options);
        }
    }).showModal().width(500).height(650)
}